<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="jsp/js/jquery-2.2.2.min.js"></script>
</head>
<script type="text/javascript">
$(document).ready(function(){
 	$("#verifyCodeImg").click(function(){
		$(this).attr("src","/jcaptcha.jpg" +"?"+ Math.random());   
	});
 	
 	$("#tijiao").click(function(){
 		var text = $("#j_captcha").val();
 		if(text == ""){
 			alert("请输入验证码");
 		}else{
	 		$.post("/validate",$("#form").serialize(),function(data){
	 			if(data == "success"){
	 				alert("验证码输入正确！");
	 			}else{
	 				alert("验证码输入错误！");
	 				$("#j_captcha").val("");
	 				$("#verifyCodeImg").attr("src","/jcaptcha.jpg" +"?"+ Math.random());
	 			}
	 		});
 		}
 	});
 	
 	
});
</script>
<body>
<form action="/validate" method="post" id="form">
<span class="fl">
	<img src="/jcaptcha.jpg" style="width:100px;height:37px;cursor:pointer"  id="verifyCodeImg"/>
	<input type="text" class="ipt fl" placeholder="请输入验证码" name="j_captcha" id="j_captcha"/>
</span>
<button type="button" id="tijiao">提交</button>
</form>
</body>
</html>